#include <SoftwareSerial.h>
//#include "ESP8266WiFi.h"
SoftwareSerial yySerial(6,7); // RX, TX  //6288 TXD-->6 ,RXD-->7

byte text1[] = {0xC7, 0xEB, 0xB0, 0xB4, 0xBC, 0xFC, 0xB2, 0xA5, 0xB7, 0xC5,      0xC7, 0xEB, 0xCA, 0xE4, 0xC8, 0xEB, 0xD2, 0xAA, 0xB2, 0xA5, 0xB7, 0xC5, 0xB5, 0xC4, 0xCE, 0xC4, 0xBC, 0xFE, 0xC3, 0xFB}; //请按键播放
byte text2[] = {0xCF, 0xB5, 0xCD, 0xB3, 0xC6, 0xF4, 0xB6, 0xAF}; //系统启动
byte text3[] = {0xC7, 0xEB, 0xCA, 0xE4, 0xC8, 0xEB, 0xD2, 0xAA, 0xB2, 0xA5, 0xB7, 0xC5, 0xB5, 0xC4, 0xCE, 0xC4, 0xBC, 0xFE, 0xC3, 0xFB}; //请输入要播放的文件名
byte text4[] = {0x53, 0x44, 0xBF, 0xA8, 0xB4, 0xED, 0xCE, 0xF3}; //SD卡错误
byte text5[] = {0xB0, 0xB4, 0xBC, 0xFC, 0xB4, 0xED, 0xCE, 0xF3}; //
byte text6[] = {0xB3, 0xAC, 0xCA, 0xB1, 0xCD, 0xCB, 0xB3, 0xF6}; //超时退出
byte text7[] = {0xC0, 0xCF, 0xC1, 0xCE, 0xCA, 0xC7, 0xC9, 0xB5, 0xB1, 0xC6};
byte text8[] = {0xB0, 0xD4, 0xB0, 0xD1, 0xB0, 0xD4, 0xB0, 0xD1};

//byte text9[] = {0xfd, 0x00, 0x0B, 0x01, 0x01, 0xD7, 0xA2, 0xD2, 0xE2, 0xCE, 0xC2, 0xB6, 0xC8, 0xB9, 0xFD, 0xB8, 0xDF};
byte text9[] = {0xfd, 0x00, 0x0B, 0x01, 0x01, 0xBE, 0xAF, 0xB8, 0xE6, 0xCB, 0xAE, 0xD6, 0xCA, 0xCE, 0xDB, 0xC8, 0xBE, 0xA3};
int length = 0;  //语音内容长度

void setup() {

  Serial.begin(9600);
  yySerial.begin(9600);

 
}

//读一段文字函数
void synout(byte yyd[] , int len)
{
  int i = 0;
  byte yuyindata[206];
  byte yihuo = 0;

  yuyindata[0] = 0xFD;   //yuyin组装前缀控制符
  yuyindata[1] = 0x00;
  yuyindata[2] = len + 3;
  yuyindata[3] = 0x01;
  yuyindata[4] = 0x01;
 

  for (int i = 0; i < len; i++)   //yuyin组装正文
  {
    yuyindata[i + 5] = yyd[i];
  }

  for (int i = 0; i < len + 5; i++)    //循环输出
  {
    yihuo = yihuo ^ yuyindata[i];
    yySerial.write(yuyindata[i]);
    Serial.println(yuyindata[i]);
  }
  yySerial.write(yihuo);//输出校验码
  delay(100);
}

void loop()    //主循环 253
/*
FD 00 21 01 01 C7 EB B0 B4 BC FC B2 A5 B7 C5 C7 EB CA E4 C8 EB D2 AA B2 A5 B7 C5 B5 C4 CE C4 BC FE C3 FB EC */
FD 00 0B 01 01 D7 A2 D2 E2 CE C2 B6 C8 B9 FD B8 DF E2
{
   length = sizeof(text9) / sizeof(byte);
   while (true){
    synout(text9, length);  //播放内容
    delay(length*200);
   }
}
